home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Open Transport / Sample Code / DTS Sample Code / Using Symantec⁄OT / OT + Symantec C++ Q&A next >
Encoding:
Text File  |  1996-11-19  |  2.9 KB  |  54 lines  |  [TEXT/ttxt]

  1. Q: I'm trying to link the Open Transport libraries with a Symantec C++ compiler but it complains that SetSelfAsClient, LoadClass, SetCurrentClient and UnloadClass aren't defined.  What's going wrong?
  2.  
  3. A: The routines that are undefined (LoadClass, etc) are part of the ASLM interface.  OT uses ASLM as it's underlying shared library system, although this fact is hidden from the developer, with the ASLM bits wrapped inside standard ".o" (for 68K) and XCOFF/PEF (for PPC) files.
  4.  
  5. The missing routines are only used by two routines OTLoadASLMLibrary and OTUnloadASLMLibrary.  These routines themselves aren't referenced anywhere, either by the API or by any other OT library.
  6.  
  7. This works with CodeWarrior because, when looks at these libraries it parses them from the top down, starting at main and branch outwards to each referenced routines.  Therefore, because OTLoadASLMLibrary is never referenced, it never detects that LoadClass is undefined, and everything works fine.
  8.  
  9. However Symantec C++ is more rigourous and it notices the missing routines.  After contacting Symantec tech support it seems that their linker is being updated to ignore routines that are undefined but only referenced from routines that are never called.
  10.  
  11. Until then, there are three possible solutions...
  12.  
  13. 1. "Link with the Apple Shared Library Manager" -- The 'correct' solution would be to link with the LibraryManagerPPC.o library provided by the ASLM Developer Kit.  Unfortunately this is not as easy as it sounds, because the Library Manager object files are heavily dependent on the runtime architecture of a specific compiler and there is no explicit support for the Symantec PPC environment.
  14.  
  15. 2. "Remove the routines" -- I'm talking with OT engineering to see whether it would make more sense to just remove the routines from "OpenTransportAppPPC.o".  There has been no progress on this front yet.
  16.  
  17. 3. "Dummy routines" -- You can simply define these routines in your own source file as shown below...
  18.  
  19. -------------------------------------------------------------
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.     
  24. void SetSelfAsClient(void)
  25. {
  26.         DebugStr("\pSetSelfAsClient -- This is not good.");
  27. }
  28.  
  29. void LoadClass(void)
  30. {
  31.         DebugStr("\pLoadClass -- This is not good.");
  32. }
  33.  
  34. void SetCurrentClient(void)
  35. {
  36.         DebugStr("\pSetCurrentClient -- This is not good.");
  37. }
  38.  
  39. void UnloadClass(void)
  40. {
  41.         DebugStr("\pUnloadClass -- This is not good.");
  42. }
  43.  
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. -------------------------------------------------------------
  48.  
  49. This should work because these routines are never actually called by any code.  The DebugStrs are there just in case that assertion turns out to be untrue.
  50.  
  51. I actually tried this workaround with the SC 8.0 compiler and everything seemed to work just fine.
  52.  
  53. By the way, the above sample uses conditional compilation to ensure that the routines are defined inside an extern "C" { } block, lest the link fail because of the name mangler.
  54.